from notes import note_from_name
import types
import string
from itertools import cycle

class Instrument( object ):
	def __init__(self):
		pass
	def getNote( self ):
		return  "c4"
	def getDuration( self ):
		return 0.1

class NoteInstrument( Instrument ):
	def __init__(self , note):
		self.note = note
	def getNote( self ):
		return   self.note 
	
class SequenceInstrument( Instrument ):
	def __init__(self , sequence ):
		if type( sequence ) is types.StringType: 
			sequence = string.split( sequence , "," )	
		self.sequence = sequence
		self.noteseq =cycle( self.sequence ) 
	def getNote(self):
		return  self.noteseq.next() 
		
gmdrummap = {
"Acoustic Bass Drum":"B2",
"Bass Drum":"C3",
"Side Stick":"C#3",
"Acoustic Snare":"D3",
"Hand Clap":"D#3",
"Electric Snare":"E3",
"Low Floor Tom":"F3",
"Closed Hi Hat":"F#3",
"High Floor Tom":"G3",
"Pedal Hi Hat":"G#3",
"Low Tom":"A3",
"Open Hi Hat":"A#3",
"Low Mid Tom":"B3",
"Hi Mid Tom":"C4",
"Crash Cymbal 1":"C#4",
"High Tom":"D4",
"Ride Cymbal 1":"D#4",
"Chinese Cymbal":"E4",
"Ride Bell":"F4",
"Tambourine":"F#4",
"Splash Cymbal":"G4",
"Cowbell":"G#4",
"Crash Cymbal 2":"A4",
"Vibra slap":"A#4",
"Ride Cymbal 2":"B4",
"Hi Bongo":"C5",
"Low Bongo":"C#5",
"Mute Hi Conga":"D5",
"Open Hi Conga":"D#5",
"Low Conga":"E5",
"High Timbale":"F5",
"Low Timbale":"F#5",
"High Agogo":"G5",
"Low Agogo":"G#5",
"Cabasa":"A5",
"Maracas":"A#5",
"Short Whistle":"B5",
"Long Whistle":"C6",
"Short Guiro":"C#6",
"Long Guiro":"D6",
"Claves":"D#6",
"Hi Wood Block":"E6",
"Low Wood Block":"F6",
"Mute Cuica":"F#6",
"Open Cuica":"G6",
"Mute Triangle":"G#6",
"Open Triangle":"A6"}

class GMDrumInstrument( NoteInstrument ):
	def __init__(self , name):
		if gmdrummap.has_key( name ):
			self.note = gmdrummap[ name ]
		else:
			self.note= "B2"
		
if __name__ == '__main__':
	instruments =  [ Instrument() , NoteInstrument( "e4" ) , SequenceInstrument( "c4,e4,g4" ) ]
	for test in instruments:
		print "------------------------"
		for idx in range( 0 , 10 ):
			print test.getNote()
	
